package com.sentinel.sentinel;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import com.alibaba.csp.sentinel.util.StringUtil;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 谢阳
 * @version 1.0
 * @date 2023/11/23 9:19
 * @description
 */
@Component
public class HeaderOriginParser implements RequestOriginParser {
    @Override
    public String parseOrigin(HttpServletRequest request) {
        String auth = request.getHeader("auth");
        return StringUtil.isBlank(auth) ? "blank" : auth;
    }
}
